package com.itheima.reggie.test;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
public class test {

    public static void main(String[] args) throws FileNotFoundException {
        // 区域
        String endpoint = "http://oss-cn-beijing.aliyuncs.com";

        //秘钥
        String accessKeyId = "LTAI5tC8MUEKsZjHCz4iVUu5";
        String accessKeySecret = "ouvcvB9hnxpBD1YbUmY7LgbVe3wILD";

        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

        // 上传文件
        InputStream inputStream = new FileInputStream("G:\\李白.jpg");

        //参数1: 桶名字  参数2: 图片上传后名字   参数3: 图片流
        ossClient.putObject("reggie-179-wyh", "haha.jpg", inputStream);

        // 关闭OSSClient。
        ossClient.shutdown();
    }

}
